/**
 * 
 */
package habitcoach.core.task;

import java.util.ArrayList;
import java.util.List;

import util.Constants;

/**
 * Create tasks
 * 
 * @author Coddy created on 2010-4-24
 * 
 */
public class TaskFactory
{
	private volatile static TaskFactory instance;

	private TaskFactory()
	{
	}

	/**
	 * Get instance of TaskFactory
	 * 
	 * @return instance of TaskFactory
	 */
	public static TaskFactory getInstance()
	{
		if (instance == null)
			synchronized (TaskFactory.class)
			{
				if (instance == null)
				{
					instance = new TaskFactory();
				}
			}
		return instance;
	}

	/**
	 * Create a Task using its default value. @see habitcoach.core.task.TaskImpl
	 * 
	 * @return
	 */
	public Task createTask()
	{
		return new TaskImpl();
	}

	public Task createTask(TaskStatus status, TaskRating rating)
	{
		return new TaskImpl(status, rating);
	}

	/**
	 * Create a list of task. The length of this list is defined in
	 * #Constants.DEFAULT_HABIT_PERIOD
	 * 
	 * @return
	 */
	public List<Task> createTaskList()
	{
		List<Task> list = new ArrayList<Task>();
		for (int i = 0; i < Constants.DEFAULT_HABIT_PERIOD; i++)
		{
			Task task = new TaskImpl();
			list.add(task);
		}

		return list;
	}
}
